package com.czy.owner.entity.generator;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.ui.archive.CarDossierFragment;
import com.czy.owner.ui.bottom.FindFragment;
import com.czy.owner.ui.bottom.MessageFragment;
import com.czy.owner.ui.bottom.PersonFragment;
import com.czy.owner.ui.bottom.ShoppingFragment2;
import com.czy.owner.ui.bottom.StoreFragment2;

/**
 * Created by wangayng on 2017/5/2 0002.
 * 首页底部数据源
 */

public class DataGenerator {
    public static final int []mTabRes = new int[]{R.mipmap.icon_shopping_normal,R.mipmap.icon_message_normal,R.mipmap.icon_store_normal,R.mipmap.icon_find_normal,R.mipmap.icon_person_normal,R.mipmap.icon_car_archives_normal};
    public static final int []mTabResPressed = new int[]{R.mipmap.icon_shopping_selector,R.mipmap.icon_message_selector,R.mipmap.icon_store_selector,R.mipmap.icon_find_selector,R.mipmap.icon_person_selector,R.mipmap.icon_car_archives_selector};
    public static final String []mTabTitle = new String[]{"商城","消息","门店","发现","我的" ,"车档案"};

    public static Fragment[] getFragments(){
        Fragment[] fragments = new Fragment[6];
        fragments[0] = new ShoppingFragment2();

        fragments[1] = new MessageFragment();
        fragments[2] = new StoreFragment2();
        fragments[3] = new FindFragment();
        fragments[4] = new PersonFragment();

        //车档案传入showBack参数0时隐藏返回按钮
        fragments[5] = new CarDossierFragment();
        Bundle argument = new Bundle();
        argument.putInt("showBack",0);
        fragments[5] .setArguments(argument);
        return fragments;
    }

    /**
     * 获取Tab 显示的内容
     * @param context
     * @param position
     * @return
     */
    public static View getTabView(Context context, int position){
        View view = LayoutInflater.from(context).inflate(R.layout.item_main_tablayout,null);
        ImageView tabIcon = (ImageView) view.findViewById(R.id.tab_image);
        tabIcon.setImageResource(DataGenerator.mTabRes[position]);
        TextView tabText = (TextView) view.findViewById(R.id.tab_title);
        tabText.setText(mTabTitle[position]);
        return view;
    }
}
